var e = getApp();

Page({
    data: {
        language: "",
        info_img: "",
        isCheck: !1,
        becomeType_1: !1,
        becomeType_2: !1,
        becomeType_3: !1,
        becomeType_4: !1,
        become_1_info_1: "",
        become_1_info_2: "",
        become_2_info_1: "0",
        become_2_info_2: "0",
        become_2_info_3: "",
        become_3_info_1: "0",
        become_3_info_2: "0",
        become_3_info_3: "",
        become_4_info_1: "",
        become_4_info_2: "",
        become_4_info_3: "",
        para_name: "",
        para_phone: "",
        para_weixin: "",
        extensionTips: "",
        areaGoods: []
    },
    onLoad: function(e) {
        this.getExtensionBanner(), this.initExtension();
    },
    onReady: function() {
        var e = wx.getStorageSync("langIndex");
        this.setData({
            language: e.en
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    getExtensionBanner: function() {
        var o = this, t = e.getNetAddresss("member.member.agentbase");
        e._getNetWork({
            url: t,
            success: function(e) {
                var t = e.data;
                1 == t.result ? o.setData({
                    info_img: t.data.banner
                }) : o.setData({
                    info_img: ""
                });
            },
            fail: function(e) {
                console.log(e.msg);
            }
        });
    },
    goHome: function() {
        wx.reLaunch({
            url: "/packageG/index/index"
        });
    },
    initExtension: function() {
        this.setData({
            isCheck: !1,
            becomeType_1: !1,
            becomeType_2: !1,
            becomeType_3: !1,
            becomeType_4: !1,
            become_1_info_1: "",
            become_1_info_2: "",
            become_2_info_1: "0",
            become_2_info_2: "0",
            become_2_info_3: "",
            become_3_info_1: "0",
            become_3_info_2: "0",
            become_3_info_3: "",
            become_4_info_1: "",
            become_4_info_2: "",
            become_4_info_3: "",
            para_name: "",
            para_phone: "",
            para_weixin: ""
        }), this.getExtensionInfo();
    },
    setView: function(e) {
        0 == e.base_info.status ? (this.setBecomeType(e.become), this.setBecomeTypeView(e.become, e)) : 1 == e.base_info.status ? this.setData({
            becomeType_1: !1,
            becomeType_2: !1,
            becomeType_3: !1,
            becomeType_4: !1,
            isCheck: !0
        }) : wx.redirectTo({
            url: "/packageA/member/distribution/distribution"
        });
    },
    setBecomeType: function(e) {
        1 == e ? this.setData({
            becomeType_1: !0,
            becomeType_2: !1,
            becomeType_3: !1,
            becomeType_4: !1
        }) : 2 == e || 3 == e ? this.setData({
            becomeType_1: !1,
            becomeType_2: !0,
            becomeType_3: !0,
            becomeType_4: !0
        }) : this.setData({
            becomeType_1: !1,
            becomeType_2: !1,
            becomeType_3: !1,
            becomeType_4: !1
        });
    },
    setBecomeTypeView: function(e, o) {
        1 == e && this.setData({
            become_1_info_1: o.base_info.parent_name,
            become_1_info_2: o.base_info.shop_name,
            para_name: o.base_info.realname,
            para_phone: o.base_info.mobile
        });
    },
    getExtensionInfo: function() {
        var o = this, t = e.getNetAddresss("member.member.shareinfo");
        e._getNetWork({
            url: t,
            success: function(e) {
                var t = e.data;
                1 == t.result && (o.setView(t.data), o.setData({
                    become_3_info_1: t.data.become_term.become_moneycount ? t.data.become_term.become_moneycount : "",
                    become_3_info_2: t.data.getCostTotalPrice ? t.data.getCostTotalPrice : "",
                    become_2_info_1: t.data.become_term.become_ordercount ? t.data.become_term.become_ordercount : "",
                    become_2_info_2: t.data.getCostTotalNum ? t.data.getCostTotalNum : "",
                    extensionTips: t.data.tip ? t.data.tip : "",
                    areaGoods: t.data.become_term.goodsinfo ? t.data.become_term.goodsinfo : "",
                    become_term_id: t.data.become_term_id,
                    become_selfmoney: t.data.become_selfmoney
                }));
            },
            fail: function(e) {
                console.log(e.msg);
            }
        });
    },
    paraNameinp: function(e) {
        var o = e.detail.value;
        this.setData({
            para_name: o
        });
    },
    paraPhoneinp: function(e) {
        var o = e.detail.value;
        this.setData({
            para_phone: o
        });
    },
    become_1_click: function() {
        if (e._isTextEmpty(this.data.para_name)) wx.showToast({
            icon: "none",
            title: "请输入真实姓名",
            duration: 1e3
        }); else if (e._isTextEmpty(this.data.para_phone)) wx.showToast({
            icon: "none",
            title: "请输入手机号",
            duration: 1e3
        }); else if (e._isMoblie(this.data.para_phone)) wx.showToast({
            icon: "none",
            title: "请输入正确的手机号",
            duration: 1e3
        }); else {
            var o = "";
            try {
                var t = wx.getStorageSync("mid");
                t && (o = t);
            } catch (e) {}
            var n = this, a = e.getNetAddresss("member.member.addAgentApply");
            a += "&mid=" + o, a += "&realname=" + this.data.para_name, a += "&mobile=" + this.data.para_phone, 
            e._getNetWork({
                url: a,
                success: function(e) {
                    1 == e.data.result && n.getExtensionInfo();
                },
                fail: function(e) {
                    console.log(e.msg);
                }
            });
        }
    },
    gotoShopGood: function() {
        wx.navigateTo({
            url: "/packageA/member/extension/ExtensionGoods/ExtensionGoods"
        });
    },
    become_3_click: function() {
        wx.reLaunch({
            url: "/packageG/index/index"
        });
    }
});